import BraftEditor from 'braft-editor'
import 'braft-editor/dist/index.css'
import { useState } from 'react'
const Com = () => {

    const [ editorState, setEditorState ] = useState(BraftEditor.createEditorState('<p>Hello <b>World!</b></p>'),)
    const [ outputHTML, setOutputHTML ] = useState('')
    const handleChange = (editorState) => {
      setEditorState(editorState)
      setOutputHTML(editorState.toHTML())
    }
    return (
      <div>
        富文本编辑器
        <BraftEditor
          value={ editorState }
          onChange={ handleChange }
        />
        渲染数据：
        { outputHTML }
        预览效果
        <div dangerouslySetInnerHTML = {{ __html: outputHTML }}></div>
      </div>
    )
}

export default Com